package com.example.gfsquadwebviewproject.util;

import android.util.Log;

public class PingIp {
    String TAG = "PingIp";

    /**
     * =========通过ip ping 来判断ip是否通
     * @param ip
     */
    private void judgeTheConnect(String ip) {
        try {
            if (ip != null) {
                //代表ping 2 次 超时时间为5秒
                Process p = Runtime.getRuntime().exec("ping -c 2 -w 5 " + ip);//ping3次
                int status = p.waitFor();
                if (status == 0) {
                    Log.e(TAG,"成功");
                } else {
                    Log.e(TAG,"失败");
                }
            } else {
                Log.e(TAG,"IP为空");
            }
        } catch (Exception e) {
            Log.e(TAG,"judgeTheConnect error:"+ e.getMessage());
        }
    }

}
